var vueApp = new Vue({
  el: '#app',
  data: function () {
    return {
    	items: [
    	        {href:'###',src:'../plugin/images/ico-img01.jpg'},
    	        {href:'###',src:'../plugin/images/ico-img02.jpg'},
    	        {href:'###',src:'../plugin/images/ico-img03.jpg'},
    	        {href:'###',src:'../plugin/images/ico-img04.jpg'},
    	        {href:'###',src:'../plugin/images/ico-img05.jpg'}
    	        ],
        unReadCnt:0,
        msglist:[],
        content:''
      };
  },
  mounted: function () {
	  this.initData();
  },
  methods: {	  
	  initData:function(){
		  this.initMsgList();
	  },
	  initMsgList:function(){
		  var that = this;
	      var postdata = {
	      };        
	      var data = tools.ajaxRequestEx("pub/msg/msgList",postdata);
	      if (data.respCode == "0") {
	         this.msglist = data.list;
	         this.unReadCnt = data.unReadCnt;
	      }else {
	    	 this.msglist = [];
	         this.showError(data.respDesc);     
	         return false;
	      }  	
	  },
	  read:function(item){
		  this.content = item.msg_cont;
		  if(item.read_status=='read_status_0'){
			  var jsonStr={"detail_id": item.detail_id};
			  var postdata = {
				"jsonStr":JSON.stringify(jsonStr)
			  }
			  var data = tools.ajaxRequestEx("pub/msg/userReadMsg",postdata);
		      if (data.respCode == "0") {
		         item.read_status = "read_status_1";
		         item.read_status_name = "已阅读";
		         this.unReadCnt -=1;
		      }else {
		         this.showError(data.respDesc);     
		         return false;
		      }  	
		  }
	  },
      showError: function(info){
          var i = (info==undefined?"加载数据错误":info);
          this.$alert(i, '系统错误', {
               confirmButtonText: '确定'
          }); 
      },
    },
  watch:{
      
  }
});
